package xyz.lilei123.sessiondemo.rest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import xyz.lilei123.sessiondemo.dto.UserDto;
import xyz.lilei123.sessiondemo.service.IUserService;

import javax.annotation.PostConstruct;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


/**
 * @author jack
 * @version 1.0
 * @date 05/09/2021 15:44
 **/
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;


    @GetMapping(value="/get")
    public String getUser(@SessionAttribute("username") String name, HttpSession session) {
        System.out.println("----获取username:"+name);
        session.setAttribute("userId", userService.getUserByName(name).getId());
        return "result";

    }



}
